package interview9;

import java.util.Stack;

/**
 * @author Jack
 * @date 2019-11-05-10:52
 */
public class Solution {

    private Stack<Object> stack1;
    private Stack<Object> stack2;

    public Solution(){
        stack1 = new Stack<>();
        stack2 = new Stack<>();
    }

    /**
     * 插入节点
     * @param obj
     */
    public void appendTail(Object obj){
        stack1.push(obj);
    }

    /**
     * 删除队头节点
     * @return
     */
    public Object deleteHead() throws Exception {
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        if(stack2.isEmpty()){
            throw new Exception("队列为空!");
        }
        return stack2.pop();
    }



}
